//
//  PlayRightViewCell.swift
//  TianTianBiTing
//
//  Created by Gox mac 2 on 2018/12/27.
//  Copyright © 2018 Gox_WallyDiao. All rights reserved.
//

import UIKit

class PlayRightViewCell: UITableViewCell {
    @IBOutlet weak var backImage: UIImageView!
    @IBOutlet weak var topImage: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var detailsLabel: UILabel!
//    @IBOutlet weak var listenBtn: UIButton!
    @IBOutlet weak var ListenLabel: UILabel!
    
    var everySeasonBuy:Int = 0 // 是否支持分集购买 0:不支持 1:支持
    
    var model = PlayListModel()
    var modelList: PlayListModel? {
        didSet {
            guard let model = modelList else { return }
            self.model = model
            setData()
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        setUI()
    }
    
    func setUI() {
        self.backImage.layer.cornerRadius = 3
        self.topImage.layer.cornerRadius = 3
        self.ListenLabel.layer.borderWidth = 1
        self.ListenLabel.layer.borderColor = UIColor.clear.cgColor
        self.ListenLabel.layer.cornerRadius = 4
        self.ListenLabel.layer.masksToBounds = true
    }
    
    func setData() {
        self.backImage.sd_setImage(with: URL(string: StringIncludeChineseToString(self.model.imageUrl ?? "")), completed: nil)
        self.topImage.isHidden = true
        self.ListenLabel.isHidden = true
        if self.model.buySelf == 0 {
            self.ListenLabel.isHidden = false
            if self.model.tryStatus == 1 {
                self.topImage.isHidden = false
                if self.everySeasonBuy == 0 {
                    self.ListenLabel.isHidden = true
//                    self.isUserInteractionEnabled = false
                } else {
                    self.ListenLabel.text = "\(String.money(self.model.price!)!)听币"
                }
                
            } else {
                self.ListenLabel.text = "试听"
            }
        } else {
            self.topImage.isHidden = true
            self.ListenLabel.isHidden = true
        }

        self.titleLabel.text = "第\(self.model.season ?? "")集：\(self.model.title ?? "")"
        self.detailsLabel.text = self.model.describe
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
